package com.gzx.plugin.ams.modular.reminder.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.ams.modular.reminder.bo.GzxRenewalMattersAddOrEditBo;
import com.gzx.plugin.ams.modular.reminder.bo.GzxRenewalMattersQueryBo;
import com.gzx.plugin.ams.modular.reminder.service.GzxRenewalService;
import com.gzx.plugin.ams.modular.reminder.vo.GzxRenewalMattersVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

/**
 * @author zjt
 * @description
 * @date 2025/6/23 18:04
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/ams/renewal")
public class GzxRenewalController {

    private final GzxRenewalService renewalService;

    @PostMapping("/pageList")
    public CommonResult<Page<GzxRenewalMattersVo>> pageList(@RequestBody GzxRenewalMattersQueryBo renewalMattersQueryBo) {
        return CommonResult.data(renewalService.pageList(renewalMattersQueryBo));
    }

    @CommonLog("新增续费事项")
    @PostMapping("/add")
    public CommonResult<Void> add(@RequestBody GzxRenewalMattersAddOrEditBo renewalMattersAddOrEditBo) {
        renewalService.insertMatters(renewalMattersAddOrEditBo);
        return CommonResult.ok();
    }

    @CommonLog("修改续费事项")
    @PostMapping("/edit")
    public CommonResult<Void> edit(@RequestBody GzxRenewalMattersAddOrEditBo renewalMattersAddOrEditBo) {
        renewalService.updateMatters(renewalMattersAddOrEditBo);
        return CommonResult.ok();
    }

    @CommonLog("删除续费事项")
    @GetMapping("/del/{id}")
    public CommonResult<Void> del(@PathVariable Long id) {
        renewalService.delete(id);
        return CommonResult.ok();
    }
}
